# -*- coding: encoding -*-


import mysql.connector
import random as rd


def get_rand_name():
    return rd.choice(['John', 'Mike', 'Joe'])


def get_rand_url():
    return rd.choice(['www.cc.com', 'www.123.com', 'www.cx.net'])


def insert():
    conn = mysql.connector.connect(user='root', password='root', database='web_data', use_unicode=True,
                                   host="192.168.72.131", port=3306)
    cursor = conn.cursor()
    cursor.execute('delete from raw_data')
    for i in range(100):
        cursor.execute('insert into raw_data (id, url,content) values (%s, %s,%s)',
                       [i, get_rand_name(), get_rand_url()])
        print("i:" + str(i))
        conn.commit()

    cursor.close()


if __name__ == '__main__':
    insert()
